﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


public partial class CourseDetails : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
           // 
        
        int id = Convert.ToInt32(Request.QueryString["id"]);
        if (id !=0)
        {
            btnAdmin.Text = "欢迎你，" + (String)Session["name"];
        }
        string photo = Request.QueryString["photo1"];
        string conn = ConfigurationManager.ConnectionStrings["performanceConnectionString"].ConnectionString;
        string sql = "select * from course where id='" + id + "'";
        SqlDataAdapter da = new SqlDataAdapter(sql, conn);
        DataSet ds = new DataSet();
        da.Fill(ds);
        if (ds.Tables[0].Rows.Count > 0)
        {
            photo = ds.Tables[0].Rows[0]["photo"].ToString();
        }
        sql = "select * from course where photo='" + photo + "'";
        da = new SqlDataAdapter(sql, conn);
        da.Fill(ds, "course");
        dvDetails.DataSource = ds.Tables["course"];
        dvDetails.DataBind();
    }


    protected void Image2_Command(object sender, CommandEventArgs e)
    {
        Response.Redirect("HomePage.aspx");
    }

    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (btnAdmin.Text.Equals("登录"))
        {
            Response.Redirect("Login.aspx");
        }
        else
        {
            Response.Redirect("CourseChoosing.aspx");
        }
    }
}